//不需要安装依赖
//全局注册 app.use(Cors)
function Cors(req,res,next){    
    res.header('Access-Control-Allow-Origin','http://localhost:5173');
    res.header("Access-Control-Allow-Credentials",true);  
    res.header('Access-Control-Allow-Headers', 'Content-Type, Content-Length, Authorization, Accept, X-Requested-With');    
    next();
}
//需要安装依赖 npm install cors
//全局注册 app.use(cors())
//等同于 app.use(require('cors')({ origin: 'http://localhost:5173',credentials:true}));
function cors(){
    const corsOptions = {  
        origin: 'http://localhost:5173', 
        credentials:true
    };    
    return require('cors')(corsOptions)
}
module.exports={Cors,cors}